import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';

export class FindJobDto {
  @ApiProperty({ default: 1, description: '当前页' })
  @Type(() => Number)
  @IsNumber()
  page: number = 1;

  @ApiProperty({ default: 10, description: '查询条数' })
  @Type(() => Number)
  @IsNumber()
  size: number = 10;

  // @ApiProperty({ description: '启用状态' })
  // @IsOptional()
  // @Type(() => Number)
  // @IsNumber()
  // enableStatus?: number;

  // @ApiProperty({ description: '职位ID' })
  // @IsOptional()
  // @Type(() => Number)
  // @IsNumber()
  // positionId?: number;

  // @ApiProperty({ description: '用户ID' })
  // @IsOptional()
  // @IsString()
  // userId?: string;

  @ApiProperty({ description: '职位名称' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiProperty({ description: '薪资范围' })
  @IsOptional()
  @IsString()
  salary?: string;

  @ApiProperty({ description: '公司名称' })
  @IsOptional()
  @IsString()
  companyName?: string;

  @ApiProperty({ description: '热门职位' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  hot?: number;
}

export class SearchJobDto {
  @ApiProperty({ description: '职位ID列表' })
  @IsOptional()
  @IsArray()
  ids?: number[];

  @ApiProperty({ description: '薪资范围' })
  @IsOptional()
  @IsString()
  salary: string;

  @ApiProperty({ description: '薪资范围' })
  @IsOptional()
  @IsString()
  address: string;
}

export class CreateJobDto {
  @ApiProperty({ description: '公司ID' })
  @IsNotEmpty()
  @IsNumber()
  companyId: number;

  @ApiProperty({ description: '职位ID' })
  @IsNotEmpty()
  @IsNumber()
  positionId: number;

  @ApiProperty({ description: '薪资' })
  @IsNotEmpty()
  @IsString()
  salary: string;

  @ApiProperty({ description: '经验要求' })
  @IsNotEmpty()
  @IsString()
  experience: string;

  @ApiProperty({ description: '学历要求' })
  @IsNotEmpty()
  @IsString()
  education: string;

  @ApiProperty({ description: '岗位职责' })
  @IsString()
  duty: string;

  @ApiProperty({ description: '岗位要求' })
  @IsString()
  require: string;

  @ApiProperty({ description: '启用状态' })
  @IsNumber()
  enableStatus: number;
}

export class UpdateJobDto extends CreateJobDto {
  @ApiProperty({ description: 'ID' })
  @IsNotEmpty()
  @IsNumber()
  id: number;
}
